<template>
</template>

<script>
    import minishopStore from "@/muu_minishop/store/index.js"; //store模块
    import {
        mapState,
        mapMutations,
        mapActions
    } from 'vuex'
    export default {
        data() {
            return {
				urlParams: {},
				isReady: false,
                loading: true,
            }
        },
		async onLoad(options) {
			this.urlParams = options
		},
        async created() {
            
        },
        computed: {
            ...mapState({
				pageIndex: state => state.pageIndex,
                config : state => state.config, //平台配置
				minishop: state => state.minishop //应用配置
            }),
        },
        methods: {
			
			async baseIsReady() {
				//注册模块store
				await this.installStoreModule('minishop', minishopStore);
				await this.asyncConfigStore()
			},

            /**
             * @title 安装Store模块
             * @param {Object} name
             * @param {Object} module
             */
            async installStoreModule(name, module) {
                if (this.$store.hasModule(name)) return false;
                this.$store.registerModule(name, module);
            },
			
			async asyncConfigStore(){
				return new Promise((resolve, reject) => {
					this.$store.dispatch('minishop/getConfig').then((res) =>{
						//console.log('baseConfig', res)
					    this.$store.commit('minishop/UPDATE_CONFIG',res)
						this.isReady = true
						resolve(res)
					})
				})
			},
			
            /**
             * @title 卸载Store模块
             * @param {Object} name
             */
            uninstallStoreModule(name) {
                if (this.$store.hasModule(name)) {
                    this.$store.unregisterModule(name)
                }
            },
        }
    }
</script>

<style>
</style>
